<template>
	<view>
		<u-mask :show="showPopup">
			<view class="popup-warp">
				<div class="contentTitle">
					{{$t("为避免影响您正常使用,请尽快完成实名认证")}}
				</div>
				<view class="popup-box" @tap.stop>
					<u-button @click="buyScore" :custom-style="customStyle1" type="warning" hover-class="none">
						{{$t("立即认证")}}
					</u-button>
					<u-button @click="closePopup" v-if="false" :custom-style="customStyle2" type="error" hover-class="none">
						{{$t("继续使用")}}
					</u-button>
				</view>
				
				<view class="popup-box" @tap.stop style="margin-top:10px">
					<u-button @click="logOut" :custom-style="customStyle1" type="warning" hover-class="none">
						{{$t("退出登录")}}
					</u-button>
					
				</view>
				<view style="width:100%;height:25px"></view>
				
			</view>
		</u-mask>
	</view>
</template>

<script>
	// #ifndef MP-WEIXIN
	import TencentCloudChat from '@tencentcloud/chat';
	// #endif
	export default {

		name: "authNamePopup",
		props: {
			show: {
				type: Boolean,
				default: false,
				required: true,
			}
		},
		data() {
			return {
				showPopup: false,
				customStyle1: {
					width: "100%"
				},
				customStyle2: {
					color: "#d83232",
					textDecoration: "underline",
					background: "transparent"
				},
			};
		},
		mounted() {
			this.showPopup = this.show
		},
		methods: {
			logOut() {
				const agreeApp = uni.getStorageSync("agreeApp")
				
				uni.clearStorage();
				uni.clearStorageSync();
				
				if (agreeApp) uni.setStorageSync("agreeApp", agreeApp)
			
				// #ifndef MP-WEIXIN
				let chat = TencentCloudChat.create({
					SDKAppID: 1400818966
				});
				let promise1 = chat.logout();
				promise1.then(function(imResponse) {
					console.log(imResponse.data); // 登出成功
				}).catch(function(imError) {
					console.warn('logout error:', imError);
				});
				// #endif
			
				this.$u.toast(this.$t('操作成功'))
				setTimeout(() => {
					this.$u.route({
						// url: '/pages/tabbar/startPage/language'
						url: '/pages/user/login/login',
					})
				}, 2000)
				return false
			},
			closePopup() {
				this.showPopup = false
				this.$emit('change',false)
			},
			buyVip() {
				this.$u.route('pages/user/MemberCenter/MemberCenter')
			},
			buyScore() {
				this.$u.route('pages/user/register/authentication')
				// this.$u.route('pages/user/authRealName/authRealName')
				
			},
		}
	}
</script>

<style lang="scss" scoped>
	.popup-warp {
		width: 80%;
		background: #fff;
		position: fixed;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
		padding: 40rpx;
		border-radius: 10rpx;

	}

	.contentTitle {
		color: #666;
		text-align: center;
		font-weight: 600;
		margin-bottom: 100rpx;
	}

	.popup-box {
		width: 100%;

		/deep/ u-button:last-child {
			/deep/ button {
				&:after {
					border: none;
				}
			}
		}
	}
</style>